/*
 * ct_integracao_1.c
 *
 *  Created on: 05/12/2009
 *      Author: ivansalles
 */
#include <fs.h>
#include <pcb.h>

#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>

PCB pcb;

int main(){

	FILE* logoutput = stdout;

	memset(&pcb,0,sizeof(pcb));

	pcb.pid = getpid();
	pcb.user = 1;
	pcb.group = 1;
	pcb.current_dir = 0;

	int fd = open("/teste.txt","w");
	int openerrno = errno;

	if(fd == -1){
		fprintf(logoutput, "Nao foi possivel abrir arquivo /teste.txt, erro retornado %d\n", errno);
		return 1;
	}

	char buffer[] = "Caso de teste de integracao OPEN/WRITE nr 1.";

	int result = write(fd, buffer, strlen(buffer), 0);
	int writeerrno = errno;

	int resultFlush = flush(fd);
	int flusherrno = errno;

	fprintf(logoutput,"open retorno: %d \n", fd);
	fprintf(logoutput,"open errno: %d \n", openerrno);

	fprintf(logoutput,"write retorno: %d \n", result);
	fprintf(logoutput,"write errno: %d \n", writeerrno);

	fprintf(logoutput,"flush retorno: %d \n", resultFlush);
	fprintf(logoutput,"flush errno: %d \n", flusherrno);


}
